package com.baizhi.service.impl;


import com.baizhi.dao.UserMapper;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: renpu
 * @Date: 2019/2/27 23:15
 * @Description:
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Map selectAll(int rows, int page) {
        Map map=new HashMap();

        IPage<User> iPage=new Page<>(rows,page);

        IPage<User> userIPage=userMapper.selectPage(iPage,null);

        List<User> list=userIPage.getRecords();
        long count=userIPage.getTotal();

        map.put("rows",list);
        map.put("total",count);

        return map;
    }

    @Override
    public void update(int[] ids) {
        List<Integer> list=new ArrayList<>();

        for (int id:ids) {
            list.add(id);
        }

        userMapper.deleteBatchIds(list);

    }

   /* @Override*/
   /* public int selectManCount() {
        return userDao.selectManCount();
    }

    @Override
    public int selectGirlCount() {
        return userDao.selectGirlCount();
    }

    @Override
    public int everyWeekCount(int startDay, int endDay) {
        return userDao.everyWeekCount(startDay,endDay);
    }

    @Override
    public List<Map> selectProvince() {
        return userDao.selectProvince();
    }*/
}
